package com.ejoysoft.wlanyz.business;

import com.ejoysoft.common.DbConnect;
import com.ejoysoft.common.Globa;
import com.sun.crypto.provider.RSACipher;
import com.sun.swing.internal.plaf.basic.resources.basic;

import java.io.IOException;
import java.nio.charset.Charset;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Vector;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;


public class Proportion {

    private Globa globa;
    private DbConnect db;

    //构造方法
    public Proportion() {
    }

    public Proportion(Globa globa) {
        this.globa = globa;
        db = globa.db;
    }

    //构造方法 
    public Proportion(Globa globa, boolean b) {
        this.globa = globa;
        db = globa.db;
        if (b) globa.setDynamicProperty(this);
    }
    
    private String strTableName = "wlan_test_result";
    private String strTableName2 = "rm_device";
    private String strTableName3 = "WLAN_RESC_HOTPOT";
    
    //列表记录集city
    public Proportion load(ResultSet rs) throws SQLException{
    	Proportion theBean = new Proportion();
    	try {
            theBean.setStrCity(rs.getString(1));
            theBean.setTownNum(rs.getInt(2));
            theBean.setOneAcNum(rs.getInt(3));
            theBean.setTwoAcNum(rs.getInt(4));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return theBean;
    }
    
  //列表记录集town
    public Proportion load2(ResultSet rs) throws SQLException{
    	Proportion theBean = new Proportion();
    	try {
            theBean.setStrTown(rs.getString(1));
            theBean.setOneAcNum(rs.getInt(2));
            theBean.setTwoAcNum(rs.getInt(3));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return theBean;
    }
    
  //列表记录集oneac
    public Proportion load3(ResultSet rs) throws SQLException{
    	Proportion theBean = new Proportion();
    	try {
            theBean.setStrOneAc(rs.getString(1));
            theBean.setTwoAcNum(rs.getInt(2));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return theBean;
    }
    
  //列表记录集twoac
    public Proportion load4(ResultSet rs) throws SQLException{
    	Proportion theBean = new Proportion();
    	try {
            theBean.setStrTwoAc(rs.getString(1));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return theBean;
    }
    
  //列表记录集ap
    public Proportion load5(ResultSet rs) throws SQLException{
    	Proportion theBean = new Proportion();
    	try {
            theBean.setStrApName(rs.getString(1));
            theBean.setStrMac(rs.getString(2));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return theBean;
    }
    
    //查询符合条件的记录town数
    public int getCount1(String tWhere) {
        int count = 0;
        try {
            String sql = "SELECT count(DISTINCT strtown) FROM " + strTableName3 + " ";
            if(tWhere.length()>0)
            	sql = String.valueOf(sql) + String.valueOf(tWhere);
            ResultSet rs = db.executeQuery(sql);
            if (rs.next())
                count = rs.getInt(1);
            rs.close();
            return count;
        } catch (Exception ee) {
            ee.printStackTrace();
            System.out.println(ee);          
            return count;
        }
    }
    
  //查询符合条件的记录city数
    public int getCount(String tWhere) {
        int count = 0;
        DbConnect dbConnect = new DbConnect();
        try {
            String sql = "SELECT count(DISTINCT strcity) FROM " + strTableName3 +" ";
            if(tWhere.length()>0)
            	sql = String.valueOf(sql) + String.valueOf(tWhere);
            ResultSet rs = dbConnect.executeQuery(sql);
            if (rs.next())
                count = rs.getInt(1);
            rs.close();
            return count;
        } catch (Exception ee) {
            ee.printStackTrace();
            System.out.println(ee);          
            return count;
        }finally{
        	dbConnect.closeCon();
        }
    }
    
  //查询符合条件的记录oneac数
    public int getCount2(String tWhere) {
        int count = 0;
        try {
            String sql = "SELECT count(DISTINCT STRCLASSONEHP) FROM " + strTableName3 + " ";
            if(tWhere.length()>0)
            	sql = String.valueOf(sql) + String.valueOf(tWhere);
            ResultSet rs = db.executeQuery(sql);
            if (rs.next())
                count = rs.getInt(1);
            rs.close();
            return count;
        } catch (Exception ee) {
            ee.printStackTrace();
            System.out.println(ee);          
            return count;
        }
    }
    
  //查询符合条件的记录twoac数
    public int getCount3(String tWhere) {
        int count = 0;
        try {
            String sql = "SELECT count(DISTINCT STRHOTPOTNAME) FROM " + strTableName3 + " ";
            if(tWhere.length()>0)
            	sql = String.valueOf(sql) + String.valueOf(tWhere);
            System.err.println("JJJJJJJJJJ"+sql);
            ResultSet rs = db.executeQuery(sql);
            if (rs.next())
                count = rs.getInt(1);
            rs.close();
            return count;
        } catch (Exception ee) {
            ee.printStackTrace();
            System.out.println(ee);          
            return count;
        }
    }
    
  //查询符合条件的记录ap数
    public int getCount4(String tWhere) {
        int count = 0;
        try {
            String sql = "SELECT count(DEVICE_ID) FROM " + strTableName2 + "  a " +
            		"left join "+strTableName3+ " b on a.STRHOTSPOT = b.strid ";
            if(tWhere.length()>0)
            	sql = String.valueOf(sql) + String.valueOf(tWhere);
            ResultSet rs = db.executeQuery(sql);
            if (rs.next())
                count = rs.getInt(1);
            rs.close();
            return count;
        } catch (Exception ee) {
            ee.printStackTrace();
            System.out.println(ee);          
            return count;
        }
    }
    
  //列表记录city
    public Vector<Proportion> list(String where, int startRow, int rowCount) throws SQLException{
        Vector<Proportion> beans = new Vector<Proportion>();
        try {
            String sql = "SELECT strcity,COUNT(DISTINCT strtown),COUNT(DISTINCT STRCLASSONEHP),COUNT(DISTINCT STRHOTPOTNAME) FROM " 
            		+strTableName3+ "  ";
            sql = String.valueOf(sql) + String.valueOf(where) ;//+ String.valueOf(timeWhere);
            sql += " group by STRCITY ";
            sql += " order by STRCITY ";
            Statement s = db.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            if (startRow != 0 && rowCount != 0)
                s.setMaxRows((startRow + rowCount) - 1);
            ResultSet rs = s.executeQuery(sql);
            if (rs != null && rs.next()) {
                if (startRow != 0 && rowCount != 0)
                    rs.absolute(startRow);
                do {
                	Proportion theBean = new Proportion();
                    theBean = load(rs);
                    beans.addElement(theBean);
                } while (rs.next());
            }
            rs.close();
            s.close();
        } catch (Exception ee) {
            ee.printStackTrace();
        }
        return beans;
    } 
    
  //列表记录town
    public Vector<Proportion> list2(String where, int startRow, int rowCount) throws SQLException{
        Vector<Proportion> beans = new Vector<Proportion>();
        try {
            String sql = "SELECT strtown,COUNT(DISTINCT STRCLASSONEHP),COUNT(DISTINCT STRHOTPOTNAME) FROM " + strTableName3 + " ";
            sql = String.valueOf(sql) + String.valueOf(where) ;//+ String.valueOf(timeWhere);
            sql += " group by STRCITY ,strtown ";
            sql += " order by STRCITY ";
            Statement s = db.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            if (startRow != 0 && rowCount != 0)
                s.setMaxRows((startRow + rowCount) - 1);
            ResultSet rs = s.executeQuery(sql);
            if (rs != null && rs.next()) {
                if (startRow != 0 && rowCount != 0)
                    rs.absolute(startRow);
                do {
                	Proportion theBean = new Proportion();
                    theBean = load2(rs);
                    beans.addElement(theBean);
                } while (rs.next());
            }
            rs.close();
            s.close();
        } catch (Exception ee) {
            ee.printStackTrace();
        }
        return beans;
    } 
    
  //列表记录oneac
    public Vector<Proportion> list3(String where, int startRow, int rowCount) throws SQLException{
        Vector<Proportion> beans = new Vector<Proportion>();
        try {
            String sql = "SELECT  DISTINCT(STRCLASSONEHP),COUNT(DISTINCT STRHOTPOTNAME) FROM " + strTableName3 + " ";
            sql = String.valueOf(sql) + String.valueOf(where) ;//+ String.valueOf(timeWhere);
            sql += " group by STRCITY ,strtown ,STRCLASSONEHP ";
            sql += " order by STRCITY ,strtown ";
           // System.err.println(":::::::"+sql);
            Statement s = db.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            if (startRow != 0 && rowCount != 0)
                s.setMaxRows((startRow + rowCount) - 1);
            ResultSet rs = s.executeQuery(sql);
            if (rs != null && rs.next()) {
                if (startRow != 0 && rowCount != 0)
                    rs.absolute(startRow);
                do {
                	Proportion theBean = new Proportion();
                    theBean = load3(rs);
                    beans.addElement(theBean);
                } while (rs.next());
            }
            rs.close();
            s.close();
        } catch (Exception ee) {
            ee.printStackTrace();
        }
        return beans;
    } 
    
  //列表记录oneac
    public Vector<Proportion> list4(String where, int startRow, int rowCount) throws SQLException{
        Vector<Proportion> beans = new Vector<Proportion>();
        try {
            String sql = "SELECT DISTINCT(STRHOTPOTNAME)FROM " + strTableName3 + " ";
            sql = String.valueOf(sql) + String.valueOf(where) ;//+ String.valueOf(timeWhere);
            sql += " group by STRCITY ,strtown ,STRCLASSONEHP ,STRHOTPOTNAME ";
            sql += " order by STRCITY,strtown, STRCLASSONEHP  ";
            System.err.println(sql+"==================");
            Statement s = db.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            if (startRow != 0 && rowCount != 0)
                s.setMaxRows((startRow + rowCount) - 1);
            ResultSet rs = s.executeQuery(sql);
            if (rs != null && rs.next()) {
                if (startRow != 0 && rowCount != 0)
                    rs.absolute(startRow);
                do {
                	Proportion theBean = new Proportion();
                    theBean = load4(rs);
                    beans.addElement(theBean);
                } while (rs.next());
            }
            rs.close();
            s.close();
        } catch (Exception ee) {
            ee.printStackTrace();
        }
        return beans;
    } 
    
    //列表记录ap
    public Vector<Proportion> list5(String where, int startRow, int rowCount) throws SQLException{
        Vector<Proportion> beans = new Vector<Proportion>();
        try {
        	//System.err.println(where+"+++++++++++++++");
            String sql = "SELECT DISTINCT(a.DEVICE_Name), a.strmac_addr FROM " + strTableName2 + "  a " +
            		"left join "+strTableName3+ " b on a.STRHOTSPOT = b.strid ";
            sql = String.valueOf(sql) + String.valueOf(where) ;//+ String.valueOf(timeWhere);
            sql += " order by b.STRCITY,b.strtown,b.STRCLASSONEHP,b.STRHOTPOTNAME ";
            System.err.println(sql+"==================");
            Statement s = db.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            if (startRow != 0 && rowCount != 0)
                s.setMaxRows((startRow + rowCount) - 1);
            ResultSet rs = s.executeQuery(sql);
            if (rs != null && rs.next()) {
                if (startRow != 0 && rowCount != 0)
                    rs.absolute(startRow);
                do {
                	Proportion theBean = new Proportion();
                    theBean = load5(rs);
                    beans.addElement(theBean);
                } while (rs.next());
            }
            rs.close();
            s.close();
        } catch (Exception ee) {
            ee.printStackTrace();
        }
        return beans;
    } 
    
    //拿出对应城市的已测ap数
    public int getTestAp(String city,String strStartTime,String strEndTime){
    	int testApNum =0;
    	DbConnect dbConnect = new DbConnect();
    	String where =" where 1 =1 and b.strcity ='"+city+"'";
    	try {
    		if(strStartTime.equals(""))strStartTime = "1000-1-01";
            if(strEndTime.equals(""))strEndTime = "9999-12-30";
    		String timeWhere = " and c.dtcreatdate between to_date('" + strStartTime + "','yyyy-MM-dd hh24.mi.ss') and to_date('" + strEndTime + "','yyyy-MM-dd hh24.mi.ss')" ; 
       	 String sql1 = "select count(DISTINCT c.strapmac) FROM " + strTableName2 + "  a " +
    		"left join "+strTableName3+ " b on a.STRHOTSPOT = b.strid left join "+strTableName+" c on a.STRMAC_ADDR = c.strapmac ";
            sql1 = String.valueOf(sql1) + String.valueOf(where) + String.valueOf(timeWhere);
            sql1 += " group by b.STRCITY ";
            sql1 += " order by b.STRCITY ";
            ResultSet rs = dbConnect.executeQuery(sql1);
            if (rs !=null&& rs.next()) {
           	 testApNum = rs.getInt(1);
           	rs.close();
   		}
            rs.close();
		} catch (Exception e) {
			// TODO: handle exception
			System.err.println(e);
		}finally{
			dbConnect.closeCon();
		}
		return testApNum;
    }
    //拿出对应town的已测ap数
    public int getTestAp(String city,String town,String strStartTime,String strEndTime){
    	int testApNum =0;
    	DbConnect dbConnect = new DbConnect();
    	String where =" where 1 =1 and b.strcity ='"+city+"' and b.strtown = '"+town+"'";
    	try {
    		if(strStartTime.equals(""))strStartTime = "1000-1-01";
            if(strEndTime.equals(""))strEndTime = "9999-12-30";
    		String timeWhere = " and c.dtcreatdate between to_date('" + strStartTime + "','yyyy-MM-dd hh24.mi.ss') and to_date('" + strEndTime + "','yyyy-MM-dd hh24.mi.ss')" ; 
       	 String sql1 = "select count(DISTINCT c.strapmac) FROM " + strTableName2 + "  a " +
    		"left join "+strTableName3+ " b on a.STRHOTSPOT = b.strid left join "+strTableName+" c on a.STRMAC_ADDR = c.strapmac ";
            sql1 = String.valueOf(sql1) + String.valueOf(where) + String.valueOf(timeWhere);
            sql1 += " group by b.STRCITY ";
            sql1 += " order by b.STRCITY ";
            ResultSet rs = dbConnect.executeQuery(sql1);
            if (rs !=null&& rs.next()) {
           	 testApNum = rs.getInt(1);
           	rs.close();
   		}
            rs.close();
		} catch (Exception e) {
			// TODO: handle exception
			System.err.println(e);
		}finally{
			dbConnect.closeCon();
		}
		return testApNum;
    }
   
  //拿出对应oneac的已测ap数
    public int getTestAp(String city,String town,String oneac,String strStartTime,String strEndTime){
    	int testApNum =0;
    	DbConnect dbConnect = new DbConnect();
    	String where =" where 1 =1 and b.strcity ='"+city+"' and b.strtown = '"+town+"' and b.STRCLASSONEHP = '"+oneac+"' ";
    	try {
    		if(strStartTime.equals(""))strStartTime = "1000-1-01";
            if(strEndTime.equals(""))strEndTime = "9999-12-30";
    		String timeWhere = " and c.dtcreatdate between to_date('" + strStartTime + "','yyyy-MM-dd hh24.mi.ss') and to_date('" + strEndTime + "','yyyy-MM-dd hh24.mi.ss')" ; 
       	 String sql1 = "select count(DISTINCT c.strapmac) FROM " + strTableName2 + "  a " +
    		"left join "+strTableName3+ " b on a.STRHOTSPOT = b.strid left join "+strTableName+" c on a.STRMAC_ADDR = c.strapmac ";
            sql1 = String.valueOf(sql1) + String.valueOf(where) + String.valueOf(timeWhere);
            sql1 += " group by b.STRCITY ";
            sql1 += " order by b.STRCITY ";
            ResultSet rs = dbConnect.executeQuery(sql1);
            if (rs !=null&& rs.next()) {
           	 testApNum = rs.getInt(1);
           	rs.close();
   		}
            rs.close();
		} catch (Exception e) {
			// TODO: handle exception
			System.err.println(e);
		}finally{
			dbConnect.closeCon();
		}
		return testApNum;
    }
    
  //拿出对应twoac的已测ap数
    public int getTestAp(String city,String town,String oneac,String twoac, String strStartTime,String strEndTime){
    	int testApNum =0;
    	DbConnect dbConnect = new DbConnect();
    	String where =" where 1 =1 and b.strcity ='"+city+"' and b.strtown = '"+town+"' and b.STRCLASSONEHP = '"+oneac+"' and b.strhotpotname = '"+twoac+"' ";
    	try {
    		if(strStartTime.equals(""))strStartTime = "1000-1-01";
            if(strEndTime.equals(""))strEndTime = "9999-12-30";
    		String timeWhere = " and c.dtcreatdate between to_date('" + strStartTime + "','yyyy-MM-dd hh24.mi.ss') and to_date('" + strEndTime + "','yyyy-MM-dd hh24.mi.ss')" ; 
       	 String sql1 = "select count(DISTINCT c.strapmac) FROM " + strTableName2 + "  a " +
    		"left join "+strTableName3+ " b on a.STRHOTSPOT = b.strid left join "+strTableName+" c on a.STRMAC_ADDR = c.strapmac ";
            sql1 = String.valueOf(sql1) + String.valueOf(where) + String.valueOf(timeWhere);
            sql1 += " group by b.STRCITY ";
            sql1 += " order by b.STRCITY ";
            ResultSet rs = dbConnect.executeQuery(sql1);
            if (rs !=null&& rs.next()) {
           	 testApNum = rs.getInt(1);
           	rs.close();
   		}
            rs.close();
		} catch (Exception e) {
			// TODO: handle exception
			System.err.println(e);
		}finally{
			dbConnect.closeCon();
		}
		return testApNum;
    }
    
    
    
    //判断Ap是否已经测试
    public String isTest(String ApMac,String strStartTime,String strEndTime){
    	{
    		DbConnect dbConnect  = new DbConnect();
    	      try{
    	    	  if(strStartTime.equals(""))strStartTime = "1000-1-01";
    	            if(strEndTime.equals(""))strEndTime = "9999-12-30";
    	    		String timeWhere = " and dtcreatdate between to_date('" + strStartTime + "','yyyy-MM-dd hh24.mi.ss') and to_date('" + strEndTime + "','yyyy-MM-dd hh24.mi.ss')" ; 
    	    	  String sql = "select * from "+strTableName+" where strapmac = '"+ApMac+"' ";
    	    	  sql+=timeWhere;
    	    	  //System.out.println("000000000000000"+sql);
    	    	  ResultSet rs = dbConnect.executeQuery(sql);
    	    	  if(rs!=null&& rs.next()){
    	    		  rs.close();
    	    		  return "已测试";
    	    	  }
    	    	  else 
    	    		  rs.close();
    	    		  return "未测试";
    	          }
    	      catch (Exception ee) {
    	          return "未测试";
    	      }
    	      finally{
    				dbConnect.closeCon();
    			}
    	    }
    }
    
//    //调出所有地市名称
//    public ArrayList<String> getAllCitiesByName( String where)
//    {
//    	ArrayList<String>  beans = new ArrayList<String>();
//    	String sql = "select distinct(strCity) from "+strTableName3+" ";
//    	if(where!=null && where.length()>0)
//    		sql = sql +" "+where;
//    	ResultSet re = db.executeQuery(sql);
//    	try {
//    	
//			if(re != null && re.next())
//			{   //String country = re.getString("");
//				do{
//					String city = re.getString("strCity");
//					beans.add(city);
//				}while(re.next());
//			}
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//    	return beans;
//    }
  //调出所有粒度的名称用于下拉条显示
    public ArrayList<String> getByName( String where,String what)
    {
    	ArrayList<String>  beans = new ArrayList<String>();
    	String sql = "select distinct("+what+") from "+strTableName3+" ";
    	if(where!=null && where.length()>0)
    		sql = sql+where;
    	ResultSet re = db.executeQuery(sql);
    	try {
    	
			if(re != null && re.next())
			{   //String country = re.getString("");
				do{
					String date = re.getString(what);
					beans.add(date);
				}while(re.next());
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	return beans;
    }
    
  //调出所有粒度的ap名称用于下拉条显示
    public ArrayList<String> getApNames( String where)
    {
    	ArrayList<String>  beans = new ArrayList<String>();
    	String sql = "select distinct(a.DEVICE_name) from "+strTableName2+" a, "+strTableName3+ " b ";
    	if(where!=null && where.length()>0)
    		sql = sql+where;
    	//System.err.println(sql+"]]]]]]]]]]]]]]");
    	ResultSet re = db.executeQuery(sql);
    	try {
    	
			if(re != null && re.next())
			{   //String country = re.getString("");
				do{
					String date = re.getString("DEVICE_name");
					beans.add(date);
				}while(re.next());
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	return beans;
    }
    //拿到城市下面的所有ap
    public int getAp(String city){
    	DbConnect dbConnect = new DbConnect();
    	int ap = 0;
    	String sql = "select count(distinct a.device_id) from "+strTableName2 +" a, "+strTableName3+" b where a.strhotspot = b.strid and b.strcity = '"+city+"' ";
    	try {
    		ResultSet rs = dbConnect.executeQuery(sql);
    		if (rs !=null&& rs.next()) {
				ap = rs.getInt(1);
				rs.close();
				return ap;
			}
    		rs.close();
    		return ap;
		} catch (Exception e) {
			// TODO: handle exception
			return ap;
		}
		finally{
			dbConnect.closeCon();
		}
    }
    
  //拿到区县下面的所有ap
    public int getAp(String city,String town){
    	DbConnect dbConnect = new DbConnect();
    	int ap = 0;
    	String sql = "select count(distinct a.device_id) from "+strTableName2 +" a, "+strTableName3+" b where " +
    			"a.strhotspot = b.strid and b.strcity = '"+city+"' and b.strtown = '"+town+"' ";
    	try {
    		ResultSet rs = dbConnect.executeQuery(sql);
    		if (rs !=null&& rs.next()) {
				ap = rs.getInt(1);
				rs.close();
				return ap;
			}
    		rs.close();
    		return ap;
		} catch (Exception e) {
			// TODO: handle exception
			return ap;
		}
		finally{
			dbConnect.closeCon();
		}
    }

  //拿到一级热点下面的所有ap
    public int getAp(String city,String town,String oneac){
    	DbConnect dbConnect = new DbConnect();
    	int ap = 0;
    	String sql = "select count(distinct a.device_id) from "+strTableName2 +" a, "+strTableName3+" b where " +
    			"a.strhotspot = b.strid and b.strcity = '"+city+"' and b.strtown = '"+town+"' and strclassonehp = '"+oneac+"' ";
    	try {
    		ResultSet rs = dbConnect.executeQuery(sql);
    		if (rs !=null&& rs.next()) {
				ap = rs.getInt(1);
				rs.close();
				return ap;
			}
    		rs.close();
    		return ap;
		} catch (Exception e) {
			// TODO: handle exception
			return ap;
		}
		finally{
			dbConnect.closeCon();
		}
    }
    
  //拿到二级热点下面的所有ap
    public int getAp(String city,String town,String oneac,String twoac){
    	DbConnect dbConnect = new DbConnect();
    	int ap = 0;
    	String sql = "select count(distinct a.device_id) from "+strTableName2 +" a, "+strTableName3+" b where " +
    			"a.strhotspot = b.strid and b.strcity = '"+city+"' and b.strtown = '"+town+"' and strclassonehp = '"+oneac+"' and strhotpotname= '"+twoac+"' ";
    	try {
    		ResultSet rs = dbConnect.executeQuery(sql);
    		if (rs !=null&& rs.next()) {
				ap = rs.getInt(1);
				rs.close();
				return ap;
			}
    		rs.close();
    		return ap;
		} catch (Exception e) {
			// TODO: handle exception
			return ap;
		}
		finally{
			dbConnect.closeCon();
		}
    }
    
    private String strId;
    private String strNetType;//网络类型
    private String strCity;//地市
    private String strTown;//区县
    private String strApName;//AP名称
    private String strMac;//Mac地址
    private int testNum;//已测试数量
    private int APNum;//所有AP数量
    private int oneAcNum;//一级热点数量
    private String strOneAc;//一级热点
    private int twoAcNum;//二级热点数量
    private String strTwoAc;//二级热点
    private int townNum;//区县数量
    private double proportion;//比例
    
    

	public double getProportion() {
		return proportion;
	}

	public void setProportion(double proportion) {
		this.proportion = proportion;
	}

	public String getStrId() {
		return strId;
	}

	public void setStrId(String strId) {
		this.strId = strId;
	}

	

	public String getStrNetType() {
		return strNetType;
	}

	public void setStrNetType(String strNetType) {
		this.strNetType = strNetType;
	}

	public String getStrCity() {
		return strCity;
	}

	public void setStrCity(String strCity) {
		this.strCity = strCity;
	}

	public String getStrTown() {
		return strTown;
	}

	public void setStrTown(String strTown) {
		this.strTown = strTown;
	}

	public String getStrApName() {
		return strApName;
	}

	public void setStrApName(String strApName) {
		this.strApName = strApName;
	}

	public String getStrMac() {
		return strMac;
	}

	public void setStrMac(String strMac) {
		this.strMac = strMac;
	}

	public int getTestNum() {
		return testNum;
	}

	public void setTestNum(int testNum) {
		this.testNum = testNum;
	}

	public int getAPNum() {
		return APNum;
	}

	public void setAPNum(int aPNum) {
		APNum = aPNum;
	}

	public int getOneAcNum() {
		return oneAcNum;
	}

	public void setOneAcNum(int oneAcNum) {
		this.oneAcNum = oneAcNum;
	}

	public int getTwoAcNum() {
		return twoAcNum;
	}

	public void setTwoAcNum(int twoAcNum) {
		this.twoAcNum = twoAcNum;
	}

	public String getStrOneAc() {
		return strOneAc;
	}

	public void setStrOneAc(String strOneAc) {
		this.strOneAc = strOneAc;
	}

	public String getStrTwoAc() {
		return strTwoAc;
	}

	public void setStrTwoAc(String strTwoAc) {
		this.strTwoAc = strTwoAc;
	}

	public int getTownNum() {
		return townNum;
	}

	public void setTownNum(int townNum) {
		this.townNum = townNum;
	}

   
}